package com.stone.design.patterns.factory;

/**
 * @description  通用的工厂方法模式。 E： 抽象产品 T：具体商品 T继承E
 * @Time 2018/4/2 17:21
 * Created by Stone on 2018/4/2.
 */

public class ConCreateFactoryA<E> extends Factory<E> {
    @Override
    public <T extends E> T createProduct(Class<T> clz) {
        E e = null;
        try {
            e = (E) Class.forName(clz.getName()).newInstance();
        } catch (InstantiationException e1) {
            e1.printStackTrace();
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }
        return (T) e;
    }
}
